﻿<!-- <!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>a</title>
<meta charset="utf-8" />
<script src="../sys/a.js"></script>
</head>
<body>
	<script src="https://cdn.bootcss.com/jsencrypt/2.3.1/jsencrypt.min.js"></script>
	<h1>a Page</h1>
	<button id="a">获取加密秘钥</button>
	<br />
	<button id="b">解密</button>
	<script src="../jquery.min.js"></script>
	<script type="text/javascript">
		var text = "";
		var a = $("#a");
		var url = "../pub/getPublicKey";
		a.on("click", function() {
			$.get(url, function(data) {
				var encrypt = new JSEncrypt();
				var res = data.res;
				console.log("pk：" + res);
				encrypt.setPublicKey(res);
				var ori = data.ori;
				console.log("加密前的字符：" + ori);
				var enc2base64 = encrypt.encrypt(data.ori);
				console.log("加密后的字符：" + enc2base64);
				text = enc2base64;
			});
		});

		var b = $("#b");
		b.on("click", function() {
			var postUrl = "../pub/rsaDecode";
			console.log("解密前的字符：" + text);
			$.post(postUrl, JSON.stringify(text), function(data) {
				console.log("over");
			});
		});
	</script>
</body>
</html>
 -->